%a batch of image processing, all the output parameters are saved in the doucument named "data.txt"
%e.g.,the images named from test1.tif to test56.tif
% firstly,set the parameter "file='test'"
% secondly, set the loop times as "for i=1:56"
function parawrite
%file name
file='test';
%data.txt for saving the output parameter 
fid=fopen('data.txt','wt');
for i=1:56
   % for j=1:4
    file1=strcat(file,num2str(i));
    %file1=strcat(file1,num2str(j));
    p=strcat(file1,'.tif');
    para=[];
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %improved the image contrast
    ctrenhance(p);
    %gridding by using our method
    para=otsugrid('ftest.tif');
    %gridding by using mathematical morphology method
    %para=morphspotgrid('ftest.tif');
    fprintf(fid,'%s',num2str(i));
    fprintf(fid,'%c',' ');
    fprintf(fid,'%s',file1);
    fprintf(fid,'%c',' ');
    fprintf(fid,'%s',num2str(para(1:13)));
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    fprintf(fid,'%c\n',' ');
    clear file1;
    clear para;
    %end
end
fclose(fid);